#ifndef __KHEAP_H
#define __KHEAP_H

#include "typedef.h"

#define HEAP_MAGIC      0xDEADBEEF
#define END_OF_HEAP	0
#define MIN_BLOCK_SIZE  (sizeof(block_head) + sizeof(block_tail) + 10)

typedef struct bl_head {
  u32 magic;
  u32 size;
  u32 free;
  struct bl_head* next;
  struct bl_head* prev;
} block_head;

// initialzes the kernels heap
void init_heap(u32, u32);

// allocates a block of memory and returns a pointer
u32* kmalloc(u32);

// allocates memory starting on 4KB boundary
u32* kmalloc_a(u32);

// frees block of memory
void kfree(u32*);

// prints heap statistics
void print_heap();

// returns heaps size
u32 heap_size();


#endif
